﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Badminton
{
    public partial class BookStatusForm : Form
    {
        public BookStatusForm()
        {
            InitializeComponent();
            //查询状态，绑定的数据库的场地状态
            //RecleChangePhoto(); 
            //this.Refresh(); 

            string CourtStatus1 = BLL.BllOperater.GetCourtStatus(1);
            //空闲  状态时显示m_Image1
            if (CourtStatus1.Equals("空闲"))
            {
                this.pic1.Image = Properties.Resources.IconBlack;
            }
            //使用  状态时显示的图片m_Image2
            else
            {
                this.pic1.Image = Properties.Resources.Icon;
            }  
  
            string CourtStatus2 = BLL.BllOperater.GetCourtStatus(2);
            if (CourtStatus2.Equals("空闲"))
            {
                this.pic2.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic2.Image = Properties.Resources.Icon;
            }    
            string CourtStatus3 = BLL.BllOperater.GetCourtStatus(3);
            if (CourtStatus3.Equals("空闲"))
            {
                this.pic3.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic3.Image = Properties.Resources.Icon;
            }    
            string CourtStatus4 = BLL.BllOperater.GetCourtStatus(4);
            if (CourtStatus4.Equals("空闲"))
            {
                this.pic4.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic4.Image = Properties.Resources.Icon;
            }    
            string CourtStatus5 = BLL.BllOperater.GetCourtStatus(5);
            if (CourtStatus5.Equals("空闲"))
            {
                this.pic5.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic5.Image = Properties.Resources.Icon;
            }    
            string CourtStatus6 = BLL.BllOperater.GetCourtStatus(6);
            if (CourtStatus6.Equals("空闲"))
            {
                this.pic6.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic6.Image = Properties.Resources.Icon;
            }    
            string CourtStatus7 = BLL.BllOperater.GetCourtStatus(7);
            if (CourtStatus7.Equals("空闲"))
            {
                this.pic7.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic7.Image = Properties.Resources.Icon;
            }    
            string CourtStatus8 = BLL.BllOperater.GetCourtStatus(8);
            if (CourtStatus8.Equals("空闲"))
            {
                this.pic8.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic8.Image = Properties.Resources.Icon;
            }
            string CourtStatus9 = BLL.BllOperater.GetCourtStatus(9);
            if (CourtStatus9.Equals("空闲"))
            {
                this.pic9.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic9.Image = Properties.Resources.Icon;
            }  

            string CourtStatus10 = BLL.BllOperater.GetCourtStatus(10);
            if (CourtStatus10.Equals("空闲"))
            {
                this.pic10.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic10.Image = Properties.Resources.Icon;
            }
            string CourtStatus11 = BLL.BllOperater.GetCourtStatus(11);
            if (CourtStatus11.Equals("空闲"))
            {
                this.pic11.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic11.Image = Properties.Resources.Icon;
            }

            string CourtStatus12 = BLL.BllOperater.GetCourtStatus(12);
            if (CourtStatus12.Equals("空闲"))
            {
                this.pic12.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic12.Image = Properties.Resources.Icon;
            }

            string CourtStatus13 = BLL.BllOperater.GetCourtStatus(13);
            if (CourtStatus13.Equals("空闲"))
            {
                this.pic13.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic13.Image = Properties.Resources.Icon;
            }

            string CourtStatus14 = BLL.BllOperater.GetCourtStatus(14);
            if (CourtStatus14.Equals("空闲"))
            {
                this.pic14.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic14.Image = Properties.Resources.Icon;
            }

            string CourtStatus15 = BLL.BllOperater.GetCourtStatus(15);
            if (CourtStatus15.Equals("空闲"))
            {
                this.pic15.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic15.Image = Properties.Resources.Icon;
            }

            string CourtStatus16 = BLL.BllOperater.GetCourtStatus(16);
            if (CourtStatus16.Equals("空闲"))
            {
                this.pic16.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic16.Image = Properties.Resources.Icon;
            }

            string CourtStatus17 = BLL.BllOperater.GetCourtStatus(17);
            if (CourtStatus17.Equals("空闲"))
            {
                this.pic17.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic17.Image = Properties.Resources.Icon;
            }

            string CourtStatus18 = BLL.BllOperater.GetCourtStatus(18);
            if (CourtStatus18.Equals("空闲"))
            {
                this.pic18.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic18.Image = Properties.Resources.Icon;
            }

            string CourtStatus19 = BLL.BllOperater.GetCourtStatus(19);
            if (CourtStatus19.Equals("空闲"))
            {
                this.pic19.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic19.Image = Properties.Resources.Icon;
            }

            string CourtStatus20 = BLL.BllOperater.GetCourtStatus(20);
            if (CourtStatus20.Equals("空闲"))
            {
                this.pic20.Image = Properties.Resources.IconBlack;
            }
            else
            {
                this.pic20.Image = Properties.Resources.Icon;
            }


            this.Refresh();

        }

        private void BookStatusForm_Load(object sender, EventArgs e)
        {
            //this.BookStatusView.DataSource = "";
            //BingCourtData();                       
        }

        private void btnBooking_Click(object sender, EventArgs e)
        {
        }
       

        private void BookStatusForm_FormClosed(object sender, FormClosedEventArgs e)
        {
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Close();
            FormMain fm = new FormMain();
            fm.Show();
        }

        private void btnOut_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        public static int SeletedCourt;
        private void NewBookingForm(int i,string status)
        {
            if (status.Equals("空闲"))
            {
                SeletedCourt = i;
                BookingForm bf = new BookingForm();
                this.Visible = false;
                bf.Show();
            }
            else
            {
               
                MessageBox.Show("尊敬的客户你好： " + i .ToString()+ "号     这个场地已经有人在使用，请稍后再订。谢谢合作…………", "你不能订这个场", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Visible=true;
            }
        }
        private void pic1_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(1);
            NewBookingForm(1, CourtStatus);
        }
        private void pic2_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(2);
            NewBookingForm(2, CourtStatus);

        }
        private void pic3_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(3);
            NewBookingForm(3, CourtStatus);

        }
        private void pic4_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(4);
            NewBookingForm(4, CourtStatus);
        }
        private void pic5_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(5);
            NewBookingForm(5, CourtStatus);
        }
        private void pic6_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(6);
            NewBookingForm(6, CourtStatus); 
        }
        private void pic7_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(7);
            NewBookingForm(7, CourtStatus);  
        }
        private void pic8_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(8);
            NewBookingForm(8, CourtStatus);
        }
        private void pic9_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(9);
            NewBookingForm(9, CourtStatus);  
        }
        private void pic10_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(10);
            NewBookingForm(10, CourtStatus);
        }
        private void pic11_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(11);
            NewBookingForm(11, CourtStatus); 
        }
        private void pic12_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(12);
            NewBookingForm(12, CourtStatus);
        }
        private void pic13_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(13);
            NewBookingForm(13, CourtStatus);
        }
        private void pic14_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(14);
            NewBookingForm(14, CourtStatus);
        }
        private void pic15_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(15);
            NewBookingForm(15, CourtStatus);
        }
        private void pic16_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(16);
            NewBookingForm(16, CourtStatus); 
        }
        private void pic17_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(17);
            NewBookingForm(17, CourtStatus);
        }
        private void pic18_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(18);
            NewBookingForm(18, CourtStatus);  
        }
        private void pic19_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(19);
            NewBookingForm(19, CourtStatus);
        }
        private void pic20_Click(object sender, EventArgs e)
        {
            string CourtStatus = BLL.BllOperater.GetCourtStatus(20);
            NewBookingForm(20, CourtStatus); 
        }
        
    }
}